package com.os.opencv.java.chapter5;

import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;

public class Translate {

    public static void main(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

        //构建用于平移的矩阵
        Mat mat = new Mat(2, 3, CvType.CV_64F);
        double[] data = new double[]{1,0,30,0,1,50};
        mat.put(0,0,data);

        //读取图像文件并在屏幕上显示
        Mat src = Imgcodecs.imread("/Users/matt/Pictures/111.jpg");
        HighGui.imshow("src", src);
        HighGui.waitKey(0);

        //进行图像平移并在屏幕上显示平移后的图像
        Mat dst = new Mat();
        Imgproc.warpAffine(src, dst, mat, src.size());
        HighGui.imshow("translate", dst);
        HighGui.waitKey(0);

        System.exit(0);

    }
}
